1 '                 DISKCAT SORT/PRINT PROGRAM
2 '      (C) COPYRIGHT 1983 NELSON FORD  ALL RIGHTS RESERVED
3 '
10 SCREEN 0,1: WIDTH 80
20 DEFINT A-Z:	DIM F$: F$=":diskcat.dta"
23 BG=0: IF (PEEK(&H410) AND &H30)<>&H30 THEN FG=6 ELSE FG=7
24 COLOR FG, BG, BG
30 DIM X, X$, JOB, D$(2), Y$, I, N$(2,2000), LAST(2), STACK(20), N(2,2000)
40 CLS: PRINT TAB(30) "D I S K C A T":  LOCATE 5,1,0:  X=20
50 PRINT TAB(X) "1  Compare two DISKCAT.DTA files"
60 PRINT TAB(X) "2  Print DISKCAT.DTA sorted by file name"
65 PRINT TAB(X) "3  Print DISKCAT.DTA sorted by disk name"
70 PRINT TAB(X) "4  Print DISKCAT.DTA sorted by file type"
80 PRINT TAB(X) "5  Print DISKCAT.DTA sorted by file extension"
90 PRINT TAB(X) "6  Return to main program"
95 PRINT TAB(X) "7  Return to DOS": PRINT
100 PRINT TAB(X) "   Select";
110 LOCATE,X: GOSUB 150
120 IF X$<"1" OR X$>"7" THEN 110  ELSE JOB= VAL(X$)
130 ON JOB GOTO 1000,2000,2000,2000,2000,131,135
131 '
132 PRINT:PRINT:PRINT TAB(X) "What drive is DISKCAT on?  ";: GOSUB 150
133 X$=X$+":diskcat":  CHAIN X$
134 '
135 END
139 '
140 ''''''''''get keypress:
141 '
150 COLOR 16,FG: PRINT CHR$(219) CHR$(29);: COLOR FG,BG
160 X$=INKEY$: IF X$="" THEN 160 ELSE PRINT X$;
170 IF X$=CHR$(27) THEN RUN
171 IF X$=CHR$(3) THEN END ELSE RETURN
180 '
190 ''''''''''sort:
191 '
200 CLS: LOCATE 12,35: PRINT "SORTING": TOP=0 : LO=1 : HI=LAST(S)
210   WHILE 1
220	WHILE LO < HI
230 IF HI-LO >1 THEN GOTO 260
240 IF N$(S,LO)<=N$(S,HI) THEN 320
250 SWAP N$(S,LO),N$(S,HI): SWAP N(S,LO),N(S,HI)
260 J=HI+1: GOSUB 350
270 IF J-LO >= HI-J THEN GOTO 290
280 STACK(TOP+1)=J+1: STACK(TOP+2)=HI:	 HI=J-1 : GOTO 300
290 STACK(TOP+1)=LO:  STACK(TOP+2)=J-1:  LO=J+1
300 TOP=TOP+2
310	WEND
320 IF TOP=0 THEN RETURN
330 HI=STACK(TOP) : LO=STACK(TOP-1) : TOP=TOP-2
340   WEND
350 '
360 CK.PT$= N$(S,LO) : I=LO
370   WHILE 1
380 I=I+1 : IF N$(S,I) < CK.PT$ AND I<HI THEN GOTO 380
390 J=J-1 : IF N$(S,J) > CK.PT$ THEN GOTO 390
400 IF I<J THEN SWAP N$(S,I),N$(S,J): SWAP N(S,I), N(S,J)  ELSE GOTO 420
410   WEND
420 SWAP N$(S,LO),N$(S,J):  SWAP N(S,LO), N(S,J): RETURN
430 '
998 '''''''''''''compare two diskcat files:
999 '
1000 CLS:LOCATE 10,10: PRINT "Enter drives to access (must be different): ";
1010 GOSUB 150: D$(1)=X$: PRINT "  ";:  GOSUB 150:  D$(2)=X$
1020 IF D$(1)=D$(2) THEN BEEP: PRINT " different? ";: GOTO 1020
1030   FOR S=1 TO 2
1040 CLS: LOCATE 12,30: PRINT "Loading DISKCAT.DTA" S:  J=0
1050 OPEN D$(S)+F$ AS 1 LEN=74:  FIELD 1, 12 AS X$, 62 AS Y$:  FIELD 1,1 AS T$
1060 GET 1: IF T$<>"\" AND T$<>" " THEN J=J+1: N$(S,J)=X$: N(S,J)=J: GOTO 1060
1070 CLOSE:  LAST(S)= J:  GOSUB 200  'go sort
1080	NEXT
1090 'print comparison:
1100 I=1:  J=1:  L=1:  CLS:  CLOSE
1110 LOCATE 12,5: PRINT"Print comparative lists to [1] Screen or [2] Printer? ";
1120 GOSUB 150
1130 IF X$="1" THEN O$="scrn:" ELSE IF X$="2" THEN O$="lpt1:": GOSUB 1250            ELSE 1120
1140 OPEN O$ FOR OUTPUT AS #1:	CLS
1142 OPEN D$(1)+F$ AS 2 LEN=74
1143 FIELD 2, 12 AS NM$, 8 AS DSK$, 35 AS Y$, 10 AS DT$, 7 AS SZ$, 2 AS Y$
1144 FIELD 2, 1 AS T$, 73 AS Y$
1145 OPEN D$(2)+F$ AS 3 LEN=74
1146 FIELD 3, 12 AS NM2$, 8 AS DSK2$, 35 AS Y$, 10 AS DT2$, 7 AS SZ2$, 2 AS Y$
1147 FIELD 3, 1 AS T2$, 73 AS Y$
1150 GET 2, N(1,I):  GET 3, N(2,J)
1151 IF NM$<>NM2$ OR SZ$<>SZ2$ THEN 1160
1152 PRINT #1, NM$"  "SZ$"  "DSK$ TAB(40) NM2$"  "SZ2$"  "DSK2$:  I=I+1: J=J+1:      GOTO 1165
1160 IF NM$<=NM2$ THEN PRINT #1, NM$"  "SZ$"  "DSK$: I=I+1: GOTO 1170                ELSE  PRINT TAB(40) NM2$"  "SZ$"  "DSK$: J=J+1: GOTO 1170
1165 Q$=INKEY$: IF Q$="" THEN 1170 ELSE L=CSRLIN
1166 LOCATE 25,3: PRINT"1-Continue  2-Start printing over  3-Start program over  4-End  ";: GOSUB 150:  IF X$="1" THEN LOCATE L,1: GOTO 1170
1167 IF X$="2" THEN 1100  ELSE IF X$="3" THEN RUN
1169 IF X$="4" THEN END ELSE 1166
1170 L=L+1: IF O$="lpt1:"  THEN 1210
1180 IF L<=20 THEN 1200 ELSE PRINT: PRINT "Press Enter to continue."
1190 GOSUB 150: L=1: CLS
1200 GOTO 1230
1210 IF L<=50 THEN 1230
1220 LPRINT CHR$(12): GOSUB 1260: L=1
1230 IF I=<LAST(1) OR J<=LAST(2) THEN 1150
1240 GOSUB 150: RUN
1250 CLS: LOCATE 12,20: PRINT "PREPARE PRINTER & PRESS ENTER ";: GOSUB 150
1260 LPRINT TAB(30) "DISKCAT CATALOG COMPARISON": LPRINT
1262 LPRINT STRING$(31,"-") TAB(40) STRING$(31,"-")
1263 LPRINT " FILE NAME      SIZE     DISK" TAB(40) "";
1264 LPRINT " FILE NAME      SIZE     DISK"
1265 LPRINT "------------  -------  --------" TAB(40) "";
1266 LPRINT "------------  -------  --------"
1269 LPRINT: RETURN
1270 '
2000 ''''''''''''''print sorted by other fields:
2001 '
2010 CLS: LOCATE 12,20: PRINT "Which drive has DISKCAT.DTA? ";
2020 GOSUB 150: D$(1)=X$: CLS: LOCATE 12,30: PRINT "Loading data"
2030 OPEN D$(1)+F$ AS 1 LEN=74:   FIELD 1, 1 AS T$
2040 FIELD 1, 12 AS W$, 62 AS Y$                           'by name
2045 IF JOB=3 THEN FIELD 1, 12 AS Y$,  8 AS X$, 54 AS Y$   'by disk
2050 IF JOB=4 THEN FIELD 1, 20 AS Y$, 10 AS X$, 44 AS Y$   'by type
2060 IF JOB=5 THEN FIELD 1,  9 AS Y$,  3 AS X$, 62 AS Y$   'by ext.
2065 J=0:  I=0
2070 GET 1: I=I+1
2075 IF T$<>"\" AND T$<>" " THEN IF T$<>"z" THEN J=J+1: N$(1,J)=X$+W$: N(1,J)=I:     GOTO 2070 ELSE 2070
2080 LAST(1)= J
2090 S=1: GOSUB 200
2400 CLS: CLOSE: LOCATE 10
2410 PRINT TAB(30) "1  To printer"
2420 PRINT TAB(30) "2  To screen"
2430 PRINT TAB(30) "3  To disk file":  PRINT: PRINT TAB(30) "  Select";
2440 LOCATE,30:  GOSUB 150:  CLS: ON VAL(X$) GOTO 2450,2460,3000
2450 CLS: LOCATE 12,20: PRINT "Prepare printer & press Enter  ";: GOSUB 150
2451 OPEN "lpt1:" FOR OUTPUT AS #2
2452 GOTO 2500
2460 OPEN "scrn:" FOR OUTPUT AS #2
2500 '
2520 GOSUB 2610   'print page heading
2530 OPEN D$(1)+F$ AS 1 LEN=74
2540 FIELD 1, 12 AS NM$, 8 AS DSK$, 10 AS TY$, 25 AS DESCR$, 10 AS DT$, 7 AS SZ$    ,2 AS E$
2550   FOR I=1 TO LAST(1)
2560 GET 1, N(1,I)
2570 PRINT #2, NM$ " " DSK$" "TY$" "DESCR$" "DT$" "USING "###,###"; VAL(SZ$)
2571 Q$=INKEY$: IF Q$="" THEN 2580 ELSE L=CSRLIN
2572 LOCATE 25,3: PRINT"1-Continue  2-Start printing over  3-Start program over  4-End  ";: GOSUB 150:  IF X$="1" THEN LOCATE L,1: GOTO 2580
2573 IF X$="2" THEN 2400  ELSE IF X$="3" THEN RUN
2574 IF X$="4" THEN END ELSE 2571
2580 L=L+1: IF L>55 THEN PRINT #2, CHR$(12): GOSUB 2610
2590   NEXT
2600 CLOSE: GOSUB 150: RUN
2610 PRINT #2, TAB(30) "DISKCAT File Listing": PRINT #2, "":  L=1
2620 PRINT #2, " FILE NAME     DISK   FILE TYPE       DESCRIPTION             DATE      SIZE"
2630 PRINT #2, "------------ -------- --------- -------------------------  ---------- -------"
2640 RETURN
3000 LOCATE 12,20: LINE INPUT "enter output filename:  "; FI$
3010 CLS:' LOCATE 12,30: PRINT "doing it":
3020 OPEN D$(1)+F$ AS 1 LEN=74:  FIELD 1, 74 AS A$
3030 OPEN FI$ AS 2 LEN=74:       FIELD 2, 74 AS B$
3040   FOR I=1 TO LAST(1)
3050 GET 1,N(1,I):  LSET B$= A$:  PUT 2,I
3055 PRINT B$
3060   NEXT
3070 CLOSE:  CLOSE: RUN
B$
3040   FOR I=1 TO LAST(1)
3050 GET 1,N(1,I):  LSET B$= A$:  PUT 2,I
3055 PRINT B$
3060   NEX